
// 类的类型
// class Greeter {
//     greeting: string;
//     constructor(message: string) {
//         this.greeting = message;
//     }
//     greet() {
//         return "Hello, " + this.greeting;
//     }
// }
class point2D {
    x:number;
    y:number;
    constructor(x:number,y:number){
        this.x=x;
        this.y=y; 
    }
    getDistance(point:point2D){
        return point;
    }
}
class point3D {
    x:number;
    y:number;
    z:number;
    constructor(x:number,y:number,z:number){
        this.x=x;
        this.y=y;
        this.z=z; 
    }
    getDistance(point:point3D){
        return point;
    }
}
let point2D1:point2D=new point2D(1,2);
//point3D1是point2D类型的实例，point2D类型定义了x和y属性，
// point3D类型定义了x、y和z属性，point3D类型是point2D类型的子类，point3D类型的实例可以赋值给point2D类型的变量
let point3D1:point2D=new point3D(1,2,3);
console.log(point2D1.getDistance(point3D1));//point3D { x: 1, y: 2, z: 3 }
console.log(point3D1.getDistance(point2D1));//point2D { x: 1, y: 2 }
console.log(point2D1)//point2D { x: 1, y: 2 }
console.log(point3D1)//point3D { x: 1, y: 2, z: 3 }
console.log(point2D1===point3D1)//false
// let greeter: Greeter;
// greeter = new Greeter("world");
// console.log(greeter.greet());